// MadLibs.cpp : Defines the entry point for the console application.
// By Wil Hall, iDPA Summer 2013
//

#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	ifstream t("madlib.txt");
	stringstream buffer;
	string madlib;
	string word;
	int wstart;
	int wend;

	buffer << t.rdbuf();
	madlib = buffer.str();

	cout << "#####################################" << endl;
	cout << "###      Welcome to MadLibs!      ###" << endl;
	cout << "### By Wil Hall, iDPA Summer 2013 ###" << endl;
	cout << "#####################################" << endl;
	cout << endl;

	while((wstart = madlib.find("<")) != string::npos) {
		wend = madlib.find(">");

		cout << "Please enter a " << madlib.substr(wstart + 1, wend - wstart - 1) << ": ";
		getline(cin, word);

		madlib.erase(wstart, wend - wstart + 1);
		madlib.insert(wstart, word);
	}
	
	cout << endl << madlib << endl << endl;

	return 0;
}

